package cn.nfwx.tv.controller;

import android.os.Bundle;
import android.view.Gravity;
import android.view.View;

import cn.nfwx.tv.R;
import cn.nfwx.tv.base.BaseDialogFragment;

/**
 * 切换4g的时候提示
 * Created by zhouzechao on 2018/1/10.
 */
public class NetworkChangeController extends BaseDialogFragment implements View.OnClickListener {


    private NetworkChangeControllerListener networkChangeControllerListener;

    public NetworkChangeControllerListener getNetworkChangeControllerListener() {
        return networkChangeControllerListener;
    }

    public void setNetworkChangeControllerListener(NetworkChangeControllerListener networkChangeControllerListener) {
        this.networkChangeControllerListener = networkChangeControllerListener;
    }

    public interface NetworkChangeControllerListener {
        void network4gcancel();

        void network45sure();
    }

    public static NetworkChangeController newInstance() {
        NetworkChangeController fragment = new NetworkChangeController();
        return fragment;
    }

    /**
     * 是否填满整个屏幕
     */
    protected boolean isMatchParent() {
        return true;
    }

    protected boolean isOutsideTouchable() {
        return true;
    }

    //是否透明背景
    protected boolean isTranslucentBackground() {
        return true;
    }

    protected boolean isTranslucentStatus() {
        return false;
    }

    protected int getGravity() {
        return Gravity.BOTTOM;
    }

    @Override
    protected int getLayoutId() {
        return R.layout.dialog_network;
    }

    @Override
    protected void initView(Bundle savedInstanceState) {
        findView(R.id.network_free_wifi).setOnClickListener(this);
        findView(R.id.network_sure).setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.network_free_wifi:
                dismiss();
                if (networkChangeControllerListener != null) {
                    networkChangeControllerListener.network4gcancel();
                }
                break;
            case R.id.network_sure:
                dismiss();
                if (networkChangeControllerListener != null) {
                    networkChangeControllerListener.network45sure();
                }
                break;
        }
    }
}
